/*
 ============================================================================
 Name		: FlashLightSettingView.cpp
 Author	  : 
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CFlashLightSettingView implementation
 ============================================================================
 */
#include <aknviewappui.h>
#include "FlashLightSettingView.h"
#include "LemonAssistant.hrh"
#include <LemonAssistant.rsg>

CFlashLightSettingView::CFlashLightSettingView()
	{
	// No implementation required
	iContainer = NULL;
	}

CFlashLightSettingView::~CFlashLightSettingView()
	{
	DoDeactivate();
	}

CFlashLightSettingView* CFlashLightSettingView::NewLC()
	{
	CFlashLightSettingView* self = new (ELeave) CFlashLightSettingView();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CFlashLightSettingView* CFlashLightSettingView::NewL()
	{
	CFlashLightSettingView* self = CFlashLightSettingView::NewLC();
	CleanupStack::Pop(); // self;
	return self;
	}

void CFlashLightSettingView::ConstructL()
	{
	BaseConstructL(R_FLASH_LIGHT_SETTINGS_VIEW);
	}

TUid CFlashLightSettingView::Id() const
	{
	return TUid::Uid(ELemonAssistantAppViewFlashLightSetting);
	}

void CFlashLightSettingView::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case ECommandSettingChange:
			iContainer->EditItemL(ETrue);
			break;
		default:
			AppUi()->HandleCommandL(aCommand);
		}
	}

void CFlashLightSettingView::HandleStatusPaneSizeChange()
	{
	if (iContainer != NULL)
		iContainer->SetRect(ClientRect());
	}

/**
 * 
 * */
void CFlashLightSettingView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
		TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
	{
	if (iContainer == NULL)
		{
		iContainer = CFlashLightSettingList::NewL();

		iContainer->SetMopParent(this);
		iContainer->ConstructFromResourceL(R_FLASH_LIGHT_SETTING_ITEM_LIST);
		AppUi()->AddToStackL(*this, iContainer);

		iContainer->MakeVisible(ETrue);
		iContainer->SetRect(ClientRect());
		iContainer->ActivateL();

		//add your init code ...

		}
	}
void CFlashLightSettingView::DoDeactivate()
	{
	if (iContainer != NULL)
		{
		AppUi()->RemoveFromViewStack(*this, iContainer);
		delete iContainer;
		iContainer = NULL;
		}
	}
